-
Notifications
You must be signed in to change notification settings - Fork 25
enable setting upstreams dynamically via HTTP endpoint #16
Conversation
@ElvinEfendi have you seen kubernetes#2152 ? |
@ElvinEfendi are you interested in collaborating in that PR? Edit: Today I will post a temporal docker image with the content of the PR |
@aledbf thanks for the link, I did not know about it. Yeah the end goal seems to be the same, but that PR is using a different approach. I'm almost done with the proof of concept. Will polish it a bit more then make a PR upstream where we can discuss further.
I'm definitely interested, how do you see us proceed? |
I would prefer to continue in the PR already opened. Can we do that? |
@@ -167,11 +170,79 @@ func (n *NGINXController) syncIngress(item interface{}) error { | |||
if !n.isForceReload() && n.runningConfig.Equal(&pcfg) { | |||
glog.V(3).Infof("skipping backend reload (no changes detected)") | |||
return nil | |||
} else if !n.isForceReload() && len(n.runningConfig.Backends) == len(pcfg.Backends) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zrdaley this is how I ended up implementing it. The idea is to detect only Endpoints changes in case of any other change we fall back to reloading.
f6188b6
to
98a408d
Compare
77a34a5
to
50b58eb
Compare
ok, I have the first per namespace/service working load balancing
|
@@ -313,7 +313,8 @@ func buildProxyPass(host string, b interface{}, loc interface{}) string { | |||
} | |||
|
|||
// defProxyPass returns the default proxy_pass, just the name of the upstream | |||
defProxyPass := fmt.Sprintf("proxy_pass %s://%s;", proto, upstreamName) | |||
//defProxyPass := fmt.Sprintf("proxy_pass %s://%s;", proto, upstreamName) | |||
defProxyPass := fmt.Sprintf("proxy_pass %s://upstream_balancer;", proto) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be done only if the dynamic reconfiguration is enabled for the vhost/ingress
I'm also adding support for configuring load balancing algorithm per ingress at kubernetes#2167. |
This is now running in our staging environment. The image is public at To enable the dynamic configuration one needs to start the controller with The next steps are
@aledbf as you suggested I'm holding off of making upstream PR and also gave my feedback on the other PR you referenced. My priority with this PR will be to make it more stable and then implement EWMA balancing algorithm. And I'm also going to provide an extendable interface for anyone who wants to contribute with a different LB algorithm. If you wanna try this the image is linked above. The general workflow Controller side:
Lua side:
|
The change has been merged into master at #23 and upstream PR is at kubernetes#2174. No need for this PR anymore. |
The PR exposes an HTTP endpoint for configuring upstream peers, and changes controller code so that instead of reloading it POSTs the list of new upstream peers(endpoints) into Nginx.
For any change that is not an Endpoint change, it falls back to reload behaviour so the change has to be strictly Endpoint change so that it skips reloading.
Also note that skipping reload does not mean skipping updating the config file - the config file on disk gets updated as usual - this is important for resiliency.
Next steps:
certificate_by_lua
make certificate/secret updates dynamic as well@Shopify/edgescale